package org.yi.web.sys.entity;

import org.yi.core.annotation.TableBind;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.jfinal.plugin.activerecord.Model;

@TableBind(name="f_param")
public class ParamEntity extends Model<ParamEntity> {

	private static final long serialVersionUID = -4939271899088560415L;

	public static ParamEntity dao = new ParamEntity();
	
	private static final String TABLE_NAME = "f_param";
	
	/**
	 * 根据系统参数代码获取系统参数实体
	 * @param code		参数代码
	 * @return
	 */
	public ParamEntity getParamByCode(String code){
		Preconditions.checkArgument(Strings.isNullOrEmpty(code), "code can not be blank!");
		return dao.findFirst("select * from " + TABLE_NAME + " where code = ?", code);
	}
	
	/**
	 * 根据系统参数名称获取系统参数实体
	 * @param name		参数名
	 * @return
	 */
	public ParamEntity getParamByName(String name){
		Preconditions.checkArgument(Strings.isNullOrEmpty(name), "name can not be blank!");
		return dao.findFirst("select * from " + TABLE_NAME + " where name = ?", name);
	}
	
}
